/**
  ******************************************************************************
  * @file    Project/main.c 
  * @author  MCD Application Team
  * @brief   Main program body
  ******************************************************************************
  *
  ******************************************************************************
  */ 


/* Includes ------------------------------------------------------------------*/
#include "stm8s.h"
#include "taskapp.h"
#include "systask.h"
#include "system.h"
#include "motor.h"
#include "key.h"
#include "display.h"
#include "systimer.h"
#include "mbapp.h"
#include "adcctr.h"
#include "pincfg.h"
#include "key.h"
#include "timer.h"
      
/* Private defines -----------------------------------------------------------*/
void modbus_task(void);

uu16 mloop_cnt = 0;

/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

void main(void)
{
	PortInit();
	SystemInit();
	SystemClockUpdate();
	FunInit();
	SysTickInit();
    Timer2Init();

	/* Infinite loop */
	for(;;){
        IdleTask();
        MotorTask();
        modbus_task();
        KeyTask();
        DisplayTask();
        IWDG_ReloadCounter();
		mloop_cnt++;
    }  
}

/*****************************************************************************//*!
*
* @brief   creat caller tree for task with a interrupt that is not be used.
*          All the task must be called in this function    
*          this interrupt will never occur,it just to creat a caller tree; 
* @param   none
*
* @return  none
*
* @ Pass/ Fail criteria: none
*****************************************************************************/
INTERRUPT_HANDLER(AppTree_IRQHandler, 8)
{

}


#ifdef USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *   where the assert_param error has occurred.
  * @param file: pointer to the source file name
  * @param line: assert_param error line source number
  * @retval : None
  */
void assert_failed(u8* file, u32 line)
{ 
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
  }
}
#endif


/*****************************************************************************//*!
*
* @brief   Tick hook.
*               
* @param   none
*
* @return  none
*
* @ Pass/ Fail criteria: none
*****************************************************************************/
void TickIntHook()
{
	mb_rtu_timer_run(&mb.obj01);
    AdcTranslate();
    LcdNv();
}

/*****************************************************************************//*!
*
* @brief   Task switch hook.
*               
* @param   none
*
* @return  none
*
* @ Pass/ Fail criteria: none
*****************************************************************************/
void OSTaskSwHook()
{

	
}


/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
